package xyz.sunne.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.sunne.entity.User;
import xyz.sunne.exception.RequestException;
import xyz.sunne.response.ResponseResult;
import xyz.sunne.service.UserService;

import java.util.Date;

/**
 * @author Sunne
 * @version 1.0
 * @date 2021/9/24 0024
 */
@RequestMapping("user")
@RestController
@Api(tags = "活动控制器")
public class UserApi {
    @Autowired
    private UserService userService;

    @PostMapping("addUser")
    @ApiOperation("增加记录")
    public ResponseResult addUser(@RequestBody User user){
        if (!userService.save(user)){
            throw RequestException.fail("数据插入异常");
        }
        return ResponseResult.ok();
    }
}
